package com.gongren.project.job.oss;

import com.alibaba.dubbo.config.annotation.Reference;
import com.gongren.project.odd.job.rpc.api.oss.service.taskRpc.IActiveStatisticsTaskRpcService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

/**
 * @Author houzhong
 * @Date 2017/9/1 12:59
 */
@Component("activeStatisticsTask")
public class ActiveStatisticsTask {

    private static final Logger LOGGER = LoggerFactory.getLogger(ActiveStatisticsTask.class);

    @Reference
    private IActiveStatisticsTaskRpcService activeStatisticsTaskRpcService;

    /**
     * 每日凌晨1点触发，将前一天的日活量统计 存库
     * @author  xpp
     * @date 2017年8月1日 上午10:01:43
     * @throws Exception
     */
    @Transactional
    //@Scheduled(cron = "0 0 1 * * ? ")
    public void excuteActiveStatisticsTask(){

        LOGGER.info("ActiveStatisticsTask and excuteActiveStatisticsTask start");
        try {
            activeStatisticsTaskRpcService.findAllExcuteActiveStatisticsTask();

            LOGGER.info("ActiveStatisticsTask and excuteActiveStatisticsTask end");
        }catch (Exception e) {
            LOGGER.error("ActiveStatisticsTask and excuteActiveStatisticsTask：", e);
        }
    }
}
